<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<!--<div id="div1" class="container-div" style="display:none;height: auto;">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <iframe
                    id="ifm1" width="100%" height="350"
                    frameborder="0" name="todolist"
                    scrolling="auto"
            ></iframe>

        </div>
    </div>
</div>-->

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="zqTitle"/>
                        </li>

                        <li>
                            内容：<input type="text" name="zqDetails"/>
                        </li>

                        <!--<li class="select-time">-->
                        <!--<label>变更日期： </label>-->
                        <!--<input type="text" class="time-input" id="bg_startTime" placeholder="开始时间" name="params[beginTime]"/>-->
                        <!--<span>-</span>-->
                        <!--<input type="text" class="time-input" id="bg_endTime" placeholder="结束时间" name="params[endTime]"/>-->
                        <!--</li>-->

                        <li class="select-time">
                            <label>录入日期： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime1]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime1]"/>
                        </li>

                        <!--<li>-->
                        <!--图片：-->
                        <!--<select name="zqProcess" th:with="type=${@dict.getType('sys_map_status')}">-->
                        <!--<option value="">所有</option>-->
                        <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
                        <!--</select>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--审批状态：-->
                        <!--<select name="zqStatus" th:with="type=${@dict.getType('sys_approval_status')}">-->
                        <!--<option value="">所有</option>-->
                        <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
                        <!--</select>-->
                        <!--</li>-->

                        <li>
                        类别：<select id="category1" name="zqLb1"
                        data-rel="chosen">
                        <option value="">全部分类</option>
                        </select>
                        <select name="zqLb2" id="category2"
                        data-rel="chosen">
                        <option value="">全部分类</option>
                        </select>
                        <select name="zqLb3" id="category3"
                        data-rel="chosen">
                        <option value="">全部分类</option>
                        </select>
                        </li>
                        <!--<li>-->
                        <!--二级类别：-->
                        <!--<select name="zqLb2" id="category2"-->
                        <!--data-rel="chosen">-->
                        <!--<option value="">全部分类</option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--三级类别：-->
                        <!--<select name="zqLb3" id="category3"-->
                        <!--data-rel="chosen">-->
                        <!--<option value="">全部分类</option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <li>
                        区域：<select id="area1" name="zqProvince"
                        data-rel="chosen">
                        <option value="">全部省</option>
                        </select>
                            <select name="zqCity" id="area2"
                            data-rel="chosen">
                            <option value="">全部市</option>
                            </select>
                            <select name="zqCountry" id="area3"
                            data-rel="chosen">
                            <option value="">全部县</option>
                            </select>
                        </li>
                        <!--<li>-->
                        <!--选择市：-->
                        <!--<select name="zqCity" id="area2"-->
                        <!--data-rel="chosen">-->
                        <!--<option value="">全部市</option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--选择县：-->
                        <!--<select name="zqCountry" id="area3"-->
                        <!--data-rel="chosen">-->
                        <!--<option value="">全部县</option>-->
                        <!--</select>-->
                        <!--</li>-->

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                            <!--<a class="btn btn-success btn-rounded btn-sm" onclick="displaydata()"><i
                                    class="fa fa-sort-amount-asc"></i>&nbsp;大数据采集成果</a>-->
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:zhengqu:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" id="xiugai" onclick="$.operate.edit()"
               shiro:hasPermission="system:zhengqu:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" id="shanchu" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:zhengqu:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:zhengqu:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:zhengqu:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:zhengqu:remove')}]];
    var infoFlag = [[${@permission.hasPermi('system:zhengqu:info')}]];
    var shenpiFlag = [[${@permission.hasPermi('system:zhengqu:shenpi')}]];
    var avatarFlag = [[${@permission.hasPermi('system:zhengqu:avatar')}]];
    var qxg = [[${@permission.hasPermi('system:qxg:edit')}]];
    var yxg = [[${@permission.hasPermi('system:yxg:edit')}]];
    var ysh = [[${@permission.hasPermi('system:ysh:edit')}]];

    var prefix = ctx + "system/zhengqu";
    var prefix1 = ctx + "system/category";
    var prefix2 = ctx + "system/area";
    var jtRoleName = '';

    $(function () {
        initCategrey();
        initArea();
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            infoUrl: prefix + "/info/{id}",
            shenpiUrl: prefix + "/shenpi/{id}",
            avatarUrl: prefix + "/avatar/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "区划地名",
            search: false,
            showExport: true,
            onLoadSuccess: function (data) {
                mysetAction();
                if(jtRoleName=='信息员') {
                    $('#xiugai').remove();
                    $('#shanchu').remove();
                }
            },
            columns: [{
                checkbox: true
            },
                {
                    field: 'zqId',
                    title: '区划地名',
                    visible: false
                },
                {
                    field: 'zqTitle',
                    title: '标题',
                    sortable: true
                },
                // {
                // 	field : 'zqChangedate',
                // 	title : '变更日期',
                // 	sortable: true
                // },
                {
                    field: 'createTime',
                    title: '录入日期',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新日期',
                    sortable: true
                },
                {
                    field: 'zqProcess',
                    title: '图片',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.zqProcess == '已上传') {
                            return '<a href="#" onclick="avatarinfo(\'' + row.zqId + '\')">' + value + '</a>';
                        }
                        else {
                            return row.zqProcess;
                        }
                    }
                },
                {
                    field: 'zqStatus',
                    title: '审批状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.zqStatus == '驳回') {
                            return '<a href="#" onclick="shenpiinfo(\'' + row.zqId + '\')">' + value + '</a>';
                        }
                        else {
                            return row.zqStatus;
                        }
                    }
                },
                {
                    field: 'jt_ck',
                    title: '地图院数据库审批',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return mySetBtns(value, row, index,'zqId',3,qxg,yxg,ysh);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        jtRoleName = row.zqRoleName;
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + infoFlag + '" href="#" onclick="$.operate.info(\'' + row.zqId + '\')"><i class="fa fa-info"></i>快速预览</a> ');
                        if (row.zqRoleName == '管理员') {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.zqId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        else {
                            if (row.zqStatus == '审批通过') {

                            }
                            else {
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.zqId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            }
                        }
                        actions.push('<a class="btn btn-info btn-xs ' + avatarFlag + '" href="#" onclick="avatar(\'' + row.zqId + '\')"><i class="fa fa-info"></i>图面化</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + shenpiFlag + '" href="#" onclick="shenpi(\'' + row.zqId + '\')"><i class="fa fa-info"></i>审批</a> ');
                        if (row.zqRoleName == '管理员') {
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.zqId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        else {
                            if (row.zqStatus == '审批通过') {

                            }
                            else {
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.zqId + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function displaydata() {
        if ($('#div1').is(':hidden')) {

            $("#div1").show();
            if(!$('#ifm1').attr("src"))
            $('#ifm1').attr('src', dashuju + '/out/cmsInfoDetail');
        }
        else {

            $("#div1").hide();
        }
    }

    function avatar(zqId) {
        var url = prefix + '/avatar/' + zqId;
        $.modal.open("图面化操作", url);
    }

    function shenpi(zqId) {
        var url = prefix + '/shenpi/' + zqId;
        $.modal.open("审批操作", url);
    }

    function shenpiinfo(zqId) {
        var url = prefix + '/shenpiinfo/' + zqId;
        $.modal.open("审批意见", url);
    }

    function avatarinfo(zqId) {
        var url = prefix + '/avatarinfo/' + zqId;
        $.modal.open("图片预览", url);
    }

    function initCategrey() {


        cate1();
        cate2();
        $("#category1").change(function () {
            cate2();

        });
        $("#category2").change(function () {
            if($("#category2").val()==0)
            {
                cate31();
            }
            else
            {
                cate3($("#category2").val());
            }
        });

    }

    function cate1() {
        $.get(
            prefix1 + "/list?parentId=100&deptId=4",
            function (data) {
                if (data) {
                    var result = "";
                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#category1").html(result);
                }
            }, "json");
    }
    function cate31() {
        $.get(
            prefix1 + "/list?parentId=301",
            function (data) {
                if (data) {
                    $("#category3").html("<option value=''>全部分类</option>");
                }
            }, "json");
    }

    function cate2() {
        $.get(
            prefix1 + "/list?parentId=4",
            function (data) {
                if (data) {
                    $("#category2").html("<option value=''>全部分类</option>");
                    //	var result = "";
                    var result = "<option value=''>全部分类</option>";
                    $.each(data, function (n, value) {

                        if (n == 0) {
                            cate3(value.deptId);
                        }
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#category2").html(result);


                }
            }, "json");
    }

    function cate3(id) {
        $.get(
            prefix1 + "/list?parentId=" + id,
            function (data) {
                $("#category3").html("<option value=''>全部分类</option>");
                if (data) {
                    //	var result = '';
                    var result = "<option value=''>全部分类</option>";
                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });

                    $("#category3").html(result);
                }
            }, "json");
    }


    function initArea() {
        $.get(
            prefix2 + "/list?parentId=1",
            function (data) {
                if (data) {
                    var result = "<option value=''>全部省</option>";
                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#area1").html(result);
                }
            }, "json");


        $("#area1").change(function () {
            getAreaValue();
            if($("#area1").val()==0)
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area1").val(),
                    function (data) {
                        $("#area2").html("<option value=''>全部市</option>");
                    }, "json");
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                    }, "json");
            }
            else
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area1").val(),
                    function (data) {
                        $("#area2").html("<option value=''>全部市</option>");
                        if (data) {
                            var result = "<option value=''>全部市</option>";
                            $.each(data, function (n, value) {
                                result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                            });
                            $("#area2").html(result);
                        }
                    }, "json");

                if($("#area2").val()==0)
                {
                    $.get(
                        prefix2 + "/list?parentId=" + $("#area2").val(),
                        function (data) {
                            $("#area3").html("<option value=''>全部县</option>");
                        }, "json");
                }
                else
                {
                    $.get(
                        prefix2 + "/list?parentId=" + $("#area2").val(),
                        function (data) {
                            $("#area3").html("<option value=''>全部县</option>");
                            if (data) {
                                var result = "<option value=''>全部县</option>";
                                $.each(data, function (n, value) {
                                    result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                                });

                                $("#area3").html(result);
                            }
                        }, "json");
                }
            }
        });
        $("#area2").change(function () {
            getAreaValue();
            if($("#area2").val()==0)
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                    }, "json");
            }
            else
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                        if (data) {
                            var result = "<option value=''>全部县</option>";
                            $.each(data, function (n, value) {
                                result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                            });

                            $("#area3").html(result);
                        }
                    }, "json");
            }
        });

        $("#area3").change(function () {
            getAreaValue();
        });
    }

    function getAreaValue() {
        var c1 = $("#area1").val()
        var c2 = $("#area2").val()
        var c3 = $("#area3").val()

        console.log('**********: c1:' + c1 + ',' + 'c2:' + c2 + ',' + 'c3:' + c3);

    }
</script>
</body>
</html>